package com.ctgu.frequence.step1;

import com.ctgu.frequence.Utils.GetString;

import java.io.File;
import java.io.IOException;

public class TraverseDir2 {
    public static void traverseAllFiles(String dir) throws IOException {
        File file = new File(dir);
        if(!file.exists()){
            System.out.println("文件目录不存在");
            return;
        }
        File[] files = file.listFiles();
        if(files == null){
            System.out.println("文件夹为空");
            return;
        }
        for(File f : files){
            //为文件夹则递归遍历
            if(f.isDirectory()){
                traverseAllFiles(f.getAbsolutePath());
            }else{
                CountWord.countWord(GetString.getString(f));
            }
        }
    }
}
